package com.ui.listeners;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

import org.testng.IAnnotationTransformer;
import org.testng.IRetryAnalyzer;
import org.testng.annotations.ITestAnnotation;

/**
 * 动态的改变测试方法中注解的参数，这种方式主要只针对于@Test注解
 * @author Administrator
 *
 */
public class RetryListener implements IAnnotationTransformer{

	@Override
	public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
		//得到IretryAnalyzer对象
		IRetryAnalyzer iRetryAnalyzer = annotation.getRetryAnalyzer();
		
		//判断测试方法中有没有配置对应的参数
		if(iRetryAnalyzer == null){
			annotation.setRetryAnalyzer(TestngRetry.class);
		}
		
	}

}
